﻿using System;
using System.Web.Routing;
using System.Web.UI;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MvcSupplantCaching.UnitTests
{
    [TestClass]
    public class KeyBuilderTest : BaseTest
    {
        private KeyBuilder _keyBuilder;

        [TestInitialize]
        public void Initialize()
        {
            _keyBuilder = new KeyBuilder();
        }

        [TestMethod]
        public void BuildControllerKeyTest()
        {
            string controllerKey = _keyBuilder.BuildKey("Test");
            Assert.IsNotNull(controllerKey);
            Assert.AreNotEqual(string.Empty, controllerKey);
            Assert.IsTrue(controllerKey.Contains("test"));
        }

        [TestMethod]
        public void BuildControllerActionKeyTest()
        {
            string controllerAction = _keyBuilder.BuildKey("Test", "Index");
            Assert.IsNotNull(controllerAction);
            Assert.AreNotEqual(string.Empty, controllerAction);
            Assert.IsTrue(controllerAction.Contains("test") && controllerAction.Contains("index"));
        }

        [TestMethod]
        public void BuildFullKeyTest()
        {
            string fullKey = _keyBuilder.BuildKey("Test", "Index", new RouteValueDictionary { { "testKey", "testVal" } });
            Assert.IsNotNull(fullKey);
            Assert.AreNotEqual(string.Empty, fullKey);
            Assert.IsTrue(fullKey.Contains("test") && fullKey.Contains("index") && fullKey.Contains("testkey=testval"));
        }
    }
}
